let suffix = "/cheetah";
let $ = layui.jquery;
$.ajaxSetup({
    layerIndex: -1,
    beforeSend: function () {
        this.layerIndex = layer.load(0, {shade: [0.2, '#bdc3c7']});
    },
    complete: function (res) {
        console.log(res.responseJSON.code)
        // 未登录刷新页面
        if (res.responseJSON.code == -2) {
            top.window.location.reload();
        }
        layer.close(this.layerIndex);
    },
    error: function (res) {
        console.log(res)
        layer.close(this.layerIndex);
    }
});

// 获取URL参数
function getQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return decodeURI(r[2]);
    return null;
}

// 对象转 url 查询参数
function objToParam(obj) {
    return Object.keys(obj).map(key => {
        return key + '=' + obj[key]
    }).join('&')
}
